<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" media="screen" type="text/css" href="__THEMES__/style/layout.css" />
	</head>
	<body>
		
		<include file="Public:position" />
        
        <div class="a_table">
	    	<table width="100%">
			  <tr class="row" >
			    <td align="center">文件名</td>
			    <td align="center">备份时间</td>
			    <td align="center">文件大小</td>
			    <td align="center">管理选项</td>
			  </tr>
			  <php>
			function MyScandir($FilePath='./',$Order=0){
			$FilePath = opendir($FilePath);
			while (false !== ($filename = readdir($FilePath))) {
			  $FileAndFolderAyy[] = $filename;
			}
			$Order == 0 ? sort($FileAndFolderAyy) : rsort($FileAndFolderAyy);
			return $FileAndFolderAyy;
			}
			
			$FileArr = MyScandir('./backup/');
			foreach ($FileArr as $i => $n){
			        if($n != 'PHPMyAdminInitialData.sql' && $i>1){
			                $FileTime = date('Y-m-d H:i:s',filemtime('./backup/'.$n));
			                $FileSize = filesize('./backup/' . $n)/1024;
			
			                if ($FileSize < 1024){
			                        $FileSize = number_format($FileSize,2) . ' KB';
			                } else {
			                        $FileSize = '<font color="#FF0000">' . number_format($FileSize/1024,2) . '</font> MB';
			                }
			                $sAS = "<a href=\"" . U('index',array('action'=>'download','file'=>$n)) . "\">下载</a><span class=\"action_line\">|</span>";
			                $sAS .= "<a onClick=\"return confirm('确定将数据库还原到当前备份吗？');\" href=\"" . U('index',array('tag'=>$_GET['tag'],'action'=>'reduction','file'=>$n)) . "\">还原</a><span class=\"action_line\">|</span>";
			                $sAS .= "<a onClick=\"return confirm('确定删除该备份文件吗？');\" href=\"" . U('index',array('tag'=>$_GET['tag'],'action'=>'del','file'=>$n)) . "\">删除</a>";
			                echo "<tr class=\"row\">
			                <td height=\"20\" align=\"center\">$n</td>
			                <td align=\"center\">$FileTime</td>
			                <td align=\"center\">$FileSize</td>
			                <td align=\"center\">$sAS</td>
			                </tr>";
			                unset($FileTime,$FileSize,$sAS);
			        }
			}
			</php>
			  <tr class="row">
			    <td colspan="4" height="40" align="center"><input type="button" value="备份数据库" class="submit" style="width:120px; height:28px;" onClick="javascript:location.href='{:U('index',array('tag'=>$_GET['tag'],'action'=>'backup'))}'"></td>
			  </tr>
			</table>
			<br />
			<table width="100%" border="0" align="center" cellpadding="0" cellspacing="6">
			        <tr class="row">
			                <td style="color:#333333; line-height:20px;">
			                        注：1、本操作只对数据库中当前网站数据(表前缀为 "{:C('DB_PREFIX')}" 的表)进行备份。如果您的数据库中有多个网站，其它站点不受影响。<br />
			                        　　2、备份后的数据可以进行还原操作或通过 phpMyAdmin 导入。
			                </td>
			        </tr>
			</table>
        </div>
	</body>
</html>